﻿using System;

namespace Learn_base
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.WriteLine("Hello World!");

            //student stu = new student(18, "张三");

            //Console.WriteLine(stu.age);
            //Console.WriteLine(stu.name);


            var fielInfoData = new fieldInfo();
            fielInfoData.bbb = ""; // 会自动调用set方法

            Console.WriteLine(fielInfoData.bbb); // 会自动调用get方法
        }
    }

    class student
    {
        // 强制该类实例化时，必须传参
        public student (int age, string name)
        {
            this.age = age;
            this.name = name;
        }
        public int age;
        public string name;
    }


    class fieldInfo
    {
        private string _aaa;
        private string _bbb;

        public string aaa
        {
            get
            {
                Console.WriteLine("正在获取 aaa 的值...");
                return _aaa?.ToUpper(); // 加工逻辑
            }
            set
            {
                Console.WriteLine($"正在设置 aaa 的值为: {value}");
                _aaa = value?.Trim(); // 校验或处理逻辑
            }
        }

        public string bbb
        {
            get
            {
                Console.WriteLine("获取 bbb 的值");
                return _bbb;
            }
            set
            {
                if (string.IsNullOrEmpty(value))
                    throw new ArgumentException("bbb 不能为空");
                _bbb = value;
            }
        }
    }

}
